import requests
from datetime import datetime, timedelta

# 基础URL和参数
base_url = "http://43.138.150.59:8088/nbpAdmin/dataFill/startAnalyzeResolveByChannel"
channel = "AI客服-在线-会话"
force = "true"

# 开始日期和结束日期
start_date = datetime(2025, 3, 31)
end_date = datetime(2025, 3, 31)


# 循环遍历日期范围
current_date = start_date
while current_date <= end_date:
    # 格式化日期为字符串
    date_str = current_date.strftime("%Y-%m-%d")

    # 准备请求参数
    params = {
        "channels": channel,
        "date": date_str,
        "force": force
    }

    # 记录请求开始时间
    start_time = datetime.now()
    print(f"Date: {date_str},开始更新解决状态,:{start_time}")


    # 发送GET请求
    response = requests.get(base_url, params=params)

    # 记录请求结束时间
    end_time = datetime.now()

    # 计算耗时（秒）
    elapsed_time = (end_time - start_time).total_seconds()

    # 打印响应状态码和响应内容（可以根据需要调整）
    print(f"Date: {date_str}, 解决状态结束,结束时间:{end_time},耗时:{elapsed_time},Status Code: {response.status_code}, Response: {response.text[:100]}...")

    # 移动到下一天
    current_date += timedelta(days=1)